package com.ywj.recommender

import java.sql.{Connection, DriverManager, ResultSet}

object jdbctest {
  private var connection: Connection=null
  private var driver = "com.mysql.cj.jdbc.Driver"
  private var url = "jdbc:mysql://112.74.72.119:3306/dachuang"
  private var username = "dachuang"
  private var password = "Abc123456"
  def getConnection(): Unit ={
    Class.forName(driver)
    connection=DriverManager.getConnection(url,username,password)
  }
  def select(): Unit ={
    val selectSql="select name from category"
    var rs:ResultSet=connection.createStatement().executeQuery(selectSql)
    while(rs.next()){
      var name = rs.getString("name")
      println(name)
    }
  }

  def main(args: Array[String]): Unit = {
    getConnection()
    select()
  }
}
